import Vue from 'vue'

Vue.filter('splitNumber', (count) => {
  if (count === undefined || count === null) {
    return '--'
  }
  if (Number(count) >= 1000000) {
    return (count / 1000000).toFixed(1) + 'm'
  }
  if (Number(count) > 1000) {
    return (count / 1000).toFixed(1) + 'k'
  }
  if (typeof count !== 'string') {
    count = String(count)
  }
  return count.replace(/\B(?=(?:\d{3})+\b)/g, ',')
})

Vue.filter('styleNumber', count => {
  if (typeof count !== 'string') {
    count = String(count)
  }
  return count.replace(/\B(?=(?:\d{3})+\b)/g, ',')
})
